home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdarg.h>
-
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <Xm/Xm.h>
- #include <Xm/Form.h>
- #include <Xm/Frame.h>
- #include <Xm/Label.h>
- #include <Xm/List.h>
- #include <Xm/MainW.h>
- #include <Xm/MessageB.h>
- #include <Xm/PushB.h>
- #include <Xm/RowColumn.h>
- #include <Xm/SelectioB.h>
- #include <Xm/Separator.h>
- #include <Xm/TextF.h>
- #include <Xm/ToggleB.h>
- #include "Row.h"
-
- #include "vroom.h"
- #include "playmode.h"
- #include "track.h"
- #include "client.h"
- #include "ogl.h"
- #include "solo.h"
- #include "messages.h"
-
-
- /* BEGIN PROTOTYPES -S playmode.c */
- static void clearPreviewCB( Widget w, XtPointer clientData,
- XtPointer callData ) ;
- static void createResultsList( Widget parent, char position[] ) ;
- static void createSkillSelector( Widget parent ) ;
- static void enterNameCB( Widget w, int mode,
- XmPushButtonCallbackStruct *cbs ) ;
- static void placeCarsForFinish( char position[] ) ;
- static void setNameCB( Widget w, Widget textField, XtPointer callData ) ;
- static void setSkillLevelCB( Widget w, XtPointer clientData,
- XtPointer callData ) ;
- /* END PROTOTYPES -S playmode.c */
-
-
- extern Car cars[] ;
- extern PlayerStruct player[] ;
- extern int playMode ;
- extern int self ;
- extern long gameServerId ;
- extern long myHostId ;
- extern char *myName ;
- extern Widget playModeForm ;
- extern Widget localCourseForm ;
- extern Widget serverCourseForm ;
- extern Widget serverForm ;
- extern Widget resultsForm ;
- extern Widget previewForm ;
- extern Widget skillForm ;
- extern Widget nameForm ;
- extern Widget introWindow ;
- extern Widget mainWindow ;
-
-
- static float skillLevel[5] = { 0.70f, 0.775f, 0.85f, 0.925f, 1.0f } ;
-
- static int nRaces ;
- static float avgHumanRaceTime ;
-
-
- /*------------------------------------------------------------------------------
- * Create the chooser panel for selecting a playing mode.
- *----------------------------------------------------------------------------*/
- void
- createPlayModeChooser(
- Widget parent
- )
- {
- int n ;
- Arg args[20] ;
- Widget rc ;
- Widget label ;
- Widget w ;
- XmString str ;
- static char *helpFiles[] = { "intro.help", "playmode.help", NULL } ;
-
- n = 0 ;
- str = XmStringCreateLocalized( "Choose a play option:" ) ;
- XtSetArg( args[n], XmNlabelString, str ) ; n++ ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_NONE ) ; n++ ;
- XtSetArg( args[n], XmNmarginTop, 15 ) ; n++ ;
- label = XtCreateManagedWidget( "label", xmLabelWidgetClass, parent,
- args, n ) ;
- XmStringFree( str ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ) ; n++ ;
- XtSetArg( args[n], XmNtopWidget, label ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNentryAlignment, XmALIGNMENT_CENTER ) ; n++ ;
- XtSetArg( args[n], XmNorientation, XmVERTICAL ) ; n++ ;
- XtSetArg( args[n], XmNpacking, XmPACK_TIGHT ) ; n++ ;
- XtSetArg( args[n], XmNadjustLast, True ) ; n++ ;
- XtSetArg( args[n], XmNspacing, 10 ) ; n++ ;
- XtSetArg( args[n], XmNmarginHeight, 10 ) ; n++ ;
- XtSetArg( args[n], XmNmarginWidth, 10 ) ; n++ ;
- rc = XtCreateManagedWidget( "rowColumn", xmRowColumnWidgetClass, parent,
- args, n ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNmarginTop, 5 ) ; n++ ;
- XtSetArg( args[n], XmNmarginBottom, 5 ) ; n++ ;
- w = addMenuPushButton( rc, "Solo", args, n, (XtCallbackProc)enterNameCB,
- (XtPointer)VROOM_SOLO ) ;
- w = addMenuPushButton( rc, "Multi-player", args, n,
- (XtCallbackProc)enterNameCB, (XtPointer)VROOM_TEAM ) ;
- w = addMenuPushButton( rc, "Help", args, n, helpCB, helpFiles ) ;
- w = addMenuPushButton( rc, "About", args, n, aboutCB, NULL ) ;
- w = addMenuPushButton( rc, "Quit", args, n, exitCB, 0 ) ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Pick the skill level for the solo game.
- *----------------------------------------------------------------------------*/
- void
- pickSkillLevelCB(
- Widget w,
- XtPointer clientData,
- XtPointer callData
- )
- {
- busyCursor() ;
-
- createSkillSelector( skillForm ) ;
-
- setAdminForm( skillForm ) ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Automatically adjust the skill level for the solo game.
- *----------------------------------------------------------------------------*/
- void
- autoSkillLevelCB(
- Widget w,
- XtPointer clientData,
- XtPointer callData
- )
- {
- int i ;
- int firstPlace = 1 ;
- float bestRobotTime = 1e30 ;
- float nextBestRobotTime = 1e30 ;
- float skill ;
- float oldSkill ;
-
- busyCursor() ;
-
- avgHumanRaceTime = ( nRaces * avgHumanRaceTime +
- cars[self].bestLapTime ) / ( nRaces + 1 ) ;
- nRaces++ ;
-
- if( cars[self].finishTime < 99.0f * 60.0f )
- {
- for( i = 0 ; i < MAX_PLAYERS ; i++ )
- {
- if( i != self )
- {
- if( cars[i].bestLapTime < bestRobotTime )
- {
- nextBestRobotTime = bestRobotTime ;
- bestRobotTime = cars[i].bestLapTime ;
- }
- else if( cars[i].finishTime <
- nextBestRobotTime )
- {
- nextBestRobotTime = cars[i].bestLapTime;
- }
- if( cars[i].bestLapTime <
- cars[self].bestLapTime )
- {
- firstPlace = 0 ;
- }
- }
- }
- /*
- * Set this time just to get the return value. Actuall skill
- * setting is set later.
- */
- oldSkill = setRobotChars( 0.75f ) ;
- if( nextBestRobotTime < avgHumanRaceTime )
- {
- skill = ( 1.0f - 0.02f * avgHumanRaceTime /
- nextBestRobotTime ) * oldSkill ;
- }
- else
- {
- skill = 0.20f * ( 1.0f - oldSkill ) *
- nextBestRobotTime / avgHumanRaceTime +
- oldSkill ;
- }
- skill = MINFUNC( skill, 1.0f ) ;
- oldSkill = setRobotChars( skill ) ;
- }
-
- startTimeTrials( 1 ) ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Create the chooser panel for selecting a skill level.
- *----------------------------------------------------------------------------*/
- static void
- createSkillSelector(
- Widget parent
- )
- {
- int n ;
- Arg args[20] ;
- Widget rc ;
- Widget label ;
- Widget w ;
- XmString str ;
- static char *helpFiles[] = { "skill.help", NULL } ;
- static int init = 0 ;
-
- if( init == 1 )
- {
- return ;
- }
- init = 1 ;
-
- n = 0 ;
- str = XmStringCreateLocalized( "Choose a skill level:" ) ;
- XtSetArg( args[n], XmNlabelString, str ) ; n++ ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_POSITION ) ; n++ ;
- XtSetArg( args[n], XmNbottomPosition, 11 ) ; n++ ;
- label = XtCreateManagedWidget( "label", xmLabelWidgetClass, parent,
- args, n ) ;
- XmStringFree( str ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNtopPosition, 12 ) ; n++ ;
- XtSetArg( args[n], XmNbottomPosition, 22 ) ; n++ ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_POSITION ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_POSITION ) ; n++ ;
- XtSetArg( args[n], XmNleftPosition, 3 ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_POSITION ) ; n++ ;
- XtSetArg( args[n], XmNrightPosition, 97 ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_POSITION ) ; n++ ;
- w = addMenuPushButton( parent, "Easy", args, n, setSkillLevelCB,
- (XtPointer)0 ) ;
-
- XtSetArg( args[0], XmNtopPosition, 23 ) ;
- XtSetArg( args[1], XmNbottomPosition, 33 ) ;
- w = addMenuPushButton( parent, "Simple", args, n, setSkillLevelCB,
- (XtPointer)1 ) ;
-
- XtSetArg( args[0], XmNtopPosition, 34 ) ;
- XtSetArg( args[1], XmNbottomPosition, 44 ) ;
- w = addMenuPushButton( parent, "Medium", args, n, setSkillLevelCB,
- (XtPointer)2 ) ;
-
- XtSetArg( args[0], XmNtopPosition, 45 ) ;
- XtSetArg( args[1], XmNbottomPosition, 55 ) ;
- w = addMenuPushButton( parent, "Challenging", args, n, setSkillLevelCB,
- (XtPointer)3 ) ;
-
- XtSetArg( args[0], XmNtopPosition, 56 ) ;
- XtSetArg( args[1], XmNbottomPosition, 66 ) ;
- w = addMenuPushButton( parent, "Difficult", args, n, setSkillLevelCB,
- (XtPointer)4 ) ;
-
- XtSetArg( args[0], XmNtopPosition, 76 ) ;
- XtSetArg( args[1], XmNbottomPosition, 86 ) ;
- w = addMenuPushButton( parent, "Help", args, n, helpCB, helpFiles ) ;
-
- XtSetArg( args[0], XmNtopPosition, 87 ) ;
- XtSetArg( args[1], XmNbottomPosition, 97 ) ;
- w = addMenuPushButton( parent, "Quit", args, n, exitCB, 0 ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_POSITION ) ; n++ ;
- XtSetArg( args[n], XmNtopPosition, 67 ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_POSITION ) ; n++ ;
- XtSetArg( args[n], XmNbottomPosition, 75 ) ; n++ ;
- XtSetArg( args[n], XmNorientation, XmHORIZONTAL ) ; n++ ;
- w = XtCreateManagedWidget( "separator", xmSeparatorWidgetClass,
- parent, args, n ) ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Set the skill level.
- *----------------------------------------------------------------------------*/
- static void
- setSkillLevelCB(
- Widget w,
- XtPointer clientData,
- XtPointer callData
- )
- {
- busyCursor() ;
-
- playMode = VROOM_SOLO ;
-
- setRobotChars( skillLevel[(int)clientData] ) ;
-
- nRaces = 0 ;
- avgHumanRaceTime = 0.0f ;
-
- createLocalCourseSelector( localCourseForm ) ;
-
- setAdminForm( localCourseForm ) ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Start team mode of game.
- *----------------------------------------------------------------------------*/
- void
- startTeamModeCB(
- Widget w,
- XtPointer clientData,
- XtPointer callData
- )
- {
- playMode = VROOM_TEAM ;
-
- busyCursor() ;
-
- checkPorts() ;
-
- createServerSelector( serverForm ) ;
-
- setAdminForm( serverForm ) ;
-
- if( mainWindow != NULL && XtIsManaged( mainWindow ) )
- {
- controlMainWindow( 0 ) ;
- }
-
- if( introWindow != NULL && !XtIsManaged( introWindow ) )
- {
- controlIntroWindow( 1 ) ;
- }
-
- listenForServers() ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * End solo game, show results of last race.
- *----------------------------------------------------------------------------*/
- void
- showSoloResults(
- char position[]
- )
- {
- busyCursor() ;
-
- createResultsList( resultsForm, position ) ;
-
- setAdminForm( resultsForm ) ;
-
- controlMainWindow( 0 ) ;
-
- setIntroCarShot() ;
-
- controlIntroWindow( 1 ) ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * End network game, show results of last race.
- *----------------------------------------------------------------------------*/
- void
- showTeamResults(
- char position[]
- )
- {
- busyCursor() ;
-
- createResultsList( resultsForm, position ) ;
-
- setAdminForm( resultsForm ) ;
-
- controlMainWindow( 0 ) ;
-
- setIntroCarShot() ;
-
- controlIntroWindow( 1 ) ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Create the results list.
- *----------------------------------------------------------------------------*/
- static void
- createResultsList(
- Widget parent,
- char position[]
- )
- {
- int i ;
- int n ;
- int l ;
- char line[256] ;
- Arg args[10] ;
- Widget button[4] ;
- static char *labels[4] = { "New Race", "Rematch", "Quit", "Help" } ;
- XmString str ;
- static int init = 0 ;
- static Widget raceResults ;
- static Widget resultsList ;
- static char *soloHelpFiles[] = { "soloresults.help", NULL } ;
- static char *teamHelpFiles[] = { "teamresults.help", NULL } ;
-
- if( init == 0 )
- {
- init = 1 ;
-
- n = 0 ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_NONE ) ; n++ ;
- createSelectionList( "Race results:", parent, &resultsList,
- 4, button, labels, args, n ) ;
-
- if( playMode == VROOM_SOLO )
- {
- XtAddCallback( button[0], XmNactivateCallback,
- (XtCallbackProc)pickSkillLevelCB, NULL );
- XtAddCallback( button[1], XmNactivateCallback,
- (XtCallbackProc)autoSkillLevelCB, NULL );
- XtAddCallback( button[3], XmNactivateCallback,
- (XtCallbackProc)helpCB, soloHelpFiles ) ;
- }
- else
- {
- XtAddCallback( button[0], XmNactivateCallback,
- (XtCallbackProc)restartTeamCB, resultsForm ) ;
- XtAddCallback( button[3], XmNactivateCallback,
- (XtCallbackProc)helpCB, teamHelpFiles ) ;
- XtUnmanageChild( button[1] ) ;
- }
- XtAddCallback( button[2], XmNactivateCallback,
- (XtCallbackProc)exitCB, NULL ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNmarginTop, 15 ) ; n++ ;
- XtSetArg( args[n], XmNvisibleItemCount, 8 ) ; n++ ;
- XtSetValues( resultsList, args, n ) ;
- }
-
- XmListDeleteAllItems( resultsList ) ;
-
- placeCarsForFinish( position ) ;
-
- if( playMode == VROOM_SOLO || gameServerId == myHostId )
- {
- l = 1 ;
- }
- else
- {
- l = 0 ;
- }
- for( i = 0 ; i < MAX_PLAYERS ; i++ )
- {
- n = position[i] ;
- if( i == 0 && checkRaceRecord( cars[n].finishTime,
- cars[n].name, l ) )
- {
- sprintf( line, "%d - [%s] %s [New Record]", i + 1,
- longRaceTimeString( cars[n].finishTime, &l ),
- cars[n].name ) ;
- }
- else
- {
- sprintf( line, "%d - [%s] %s", i + 1,
- longRaceTimeString( cars[n].finishTime, &l ),
- cars[n].name ) ;
- }
- str = XmStringCreateLocalized( line ) ;
- XmListAddItem( resultsList, str, 0 ) ;
- XmStringFree( str ) ;
- }
-
- XmListSelectPos( resultsList, player[self].place, True ) ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Quick hack for debugging.
- *----------------------------------------------------------------------------*/
- void
- endSoloGame(
- void
- )
- {
- busyCursor() ;
-
- setWorkProc( VROOM_WP_SOLO, 0 ) ;
-
- XtUnmanageChild( localCourseForm ) ;
-
- controlMainWindow( 0 ) ;
-
- setIntroCarShot() ;
-
- createLocalCourseSelector( localCourseForm ) ;
-
- setAdminForm( localCourseForm ) ;
-
- controlIntroWindow( 1 ) ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Preview a course.
- *----------------------------------------------------------------------------*/
- void
- coursePreview(
- char *description,
- Widget courseForm
- )
- {
- int n ;
- Arg args[20] ;
- Widget w ;
- XmString str ;
- static int init = 0 ;
- static Widget label ;
-
- busyCursor() ;
-
- setAdminForm( previewForm ) ;
-
- if( init == 0 )
- {
- init = 1 ;
-
- n = 0 ;
- XtSetArg( args[n], XmNmarginTop, 5 ) ; n++ ;
- XtSetArg( args[n], XmNmarginBottom, 5 ) ; n++ ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_NONE ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_FORM ) ; n++ ;
- w = addMenuPushButton( previewForm, "Done", args, n,
- clearPreviewCB, courseForm ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNmarginTop, 5 ) ; n++ ;
- XtSetArg( args[n], XmNmarginBottom, 5 ) ; n++ ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_NONE ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_WIDGET ) ; n++;
- XtSetArg( args[n], XmNbottomWidget, w ) ; n++ ;
- label = XtCreateManagedWidget( "label", xmLabelWidgetClass,
- previewForm, args, n ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNshadowType, XmSHADOW_IN ) ; n++ ;
- XtSetArg( args[n], XmNshadowThickness, 2 ) ; n++ ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_WIDGET ) ; n++;
- XtSetArg( args[n], XmNbottomWidget, label ) ; n++ ;
- w = XtCreateManagedWidget( "frame", xmFrameWidgetClass,
- previewForm, args, n ) ;
-
- n = 0 ;
- createPreviewOglWidget( w, args, n ) ;
- }
-
- str = XmStringCreateLtoR( description, XmFONTLIST_DEFAULT_TAG ) ;
- n = 0 ;
- XtSetArg( args[n], XmNlabelString, str ) ; n++ ;
- XtSetValues( label, args, n ) ;
- XmStringFree( str ) ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Clear the preview window and show the previous form.
- *----------------------------------------------------------------------------*/
- static void
- clearPreviewCB(
- Widget w,
- XtPointer clientData,
- XtPointer callData
- )
- {
- busyCursor() ;
-
- setAdminForm( (Widget)clientData ) ;
-
- unbusyCursor() ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Position the cars based on their total race time.
- *----------------------------------------------------------------------------*/
- static void
- placeCarsForFinish(
- char position[]
- )
- {
- int i ;
- int ibest ;
- int l ;
- int place = 0 ;
- int marker[MAX_PLAYERS] ;
- float bestTime ;
-
- for( i = 0 ; i < MAX_PLAYERS ; i++ )
- {
- marker[i] = 0 ;
- }
-
- for( place = 0 ; place < MAX_PLAYERS ; place++ )
- {
- ibest = -1 ;
- for( i = 0 ; i < MAX_PLAYERS ; i++ )
- {
- if( marker[i] == 0 && ( cars[i].finishTime < bestTime ||
- ibest == -1 ) )
- {
- ibest = i ;
- bestTime = cars[i].finishTime ;
- }
- }
- player[ibest].place = place + 1 ;
- marker[ibest] = 1 ;
- }
-
- for( i = 0 ; i < MAX_PLAYERS ; i++ )
- {
- position[player[i].place-1] = i ;
- }
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Create the name entry form callback.
- *----------------------------------------------------------------------------*/
- static void
- enterNameCB(
- Widget w,
- int mode,
- XmPushButtonCallbackStruct *cbs
- )
- {
- int n ;
- Arg args[20] ;
- Widget rc ;
- Widget label ;
- Widget tf ;
- XmString str ;
- static char *helpFiles[] = { "name.help", NULL } ;
-
- playMode = mode ;
-
- n = 0 ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNentryAlignment, XmALIGNMENT_CENTER ) ; n++ ;
- XtSetArg( args[n], XmNorientation, XmVERTICAL ) ; n++ ;
- XtSetArg( args[n], XmNpacking, XmPACK_COLUMN ) ; n++ ;
- XtSetArg( args[n], XmNadjustLast, True ) ; n++ ;
- XtSetArg( args[n], XmNspacing, 10 ) ; n++ ;
- XtSetArg( args[n], XmNmarginHeight, 10 ) ; n++ ;
- XtSetArg( args[n], XmNmarginWidth, 10 ) ; n++ ;
- rc = XtCreateManagedWidget( "rowColumn", xmRowColumnWidgetClass,
- nameForm, args, n ) ;
-
- n = 0 ;
- str = XmStringCreateLocalized( "Enter your playing name:" ) ;
- XtSetArg( args[n], XmNlabelString, str ) ; n++ ;
- XtSetArg( args[n], XmNmarginTop, 5 ) ; n++ ;
- XtSetArg( args[n], XmNmarginBottom, 5 ) ; n++ ;
- XtCreateManagedWidget( "label", xmLabelWidgetClass, rc, args, n ) ;
- XmStringFree( str ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNmarginTop, 5 ) ; n++ ;
- XtSetArg( args[n], XmNmarginBottom, 5 ) ; n++ ;
- XtSetArg( args[n], XmNmaxLength, VROOM_NAMELEN - 1 ) ; n++ ;
- tf = XtCreateManagedWidget( "textField", xmTextFieldWidgetClass,
- rc, args, n ) ;
- XmTextFieldSetString( tf, myName ) ;
- XmTextFieldSetSelection( tf, 0, strlen( myName ), CurrentTime ) ;
- XmTextFieldSetInsertionPosition( tf, strlen( myName ) ) ;
-
- XtAddCallback( tf, XmNactivateCallback,
- (XtCallbackProc)setNameCB, (XtPointer)tf ) ;
-
- n = 0 ;
- addMenuPushButton( rc, "Ok", args, n, (XtCallbackProc)setNameCB,
- (XtPointer)tf ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNorientation, XmHORIZONTAL ) ; n++ ;
- XtCreateManagedWidget( "separator", xmSeparatorWidgetClass,
- rc, args, n ) ;
-
- n = 0 ;
- addMenuPushButton( rc, "Help", args, n, helpCB, helpFiles ) ;
- addMenuPushButton( rc, "Quit", args, n, exitCB, 0 ) ;
-
- setAdminForm( nameForm ) ;
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Set the player's name.
- *----------------------------------------------------------------------------*/
- static void
- setNameCB(
- Widget w,
- Widget textField,
- XtPointer callData
- )
- {
- char *newName ;
-
- busyCursor() ;
- newName = XmTextFieldGetString( textField ) ;
- if( newName != NULL && strlen( newName ) > 0 )
- {
- myName = newName ;
- }
-
- if( playMode == VROOM_SOLO )
- {
- pickSkillLevelCB( w, NULL, NULL ) ;
- }
- else
- {
- startTeamModeCB( w, NULL, NULL ) ;
- }
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Create a selection list.
- *----------------------------------------------------------------------------*/
- void
- createSelectionList(
- char *title,
- Widget parent,
- Widget *list,
- int nButtons,
- Widget *button,
- char **labels,
- Arg pArgs[],
- int pN
- )
- {
- int n ;
- int i ;
- Arg args[10] ;
- XmString str ;
- Widget row ;
- Widget label ;
- Widget form ;
- Widget form2 ;
- Widget separator ;
-
- form = XtCreateManagedWidget( "listForm", xmFormWidgetClass, parent,
- pArgs, pN ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_NONE ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNborderWidth, 0 ) ; n++ ;
- XtSetArg( args[n], XmNspacing, 15 ) ; n++ ;
- row = XtCreateManagedWidget( "row", xsRowWidgetClass,
- form, args, n ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNmarginHeight, 5 ) ; n++ ;
- XtSetArg( args[n], XmNmarginWidth, 5 ) ; n++ ;
- for( i = 0 ; i < nButtons ; i++ )
- {
- button[i] = XtCreateManagedWidget( labels[i],
- xmPushButtonWidgetClass, row, args, n ) ;
- }
-
- n = 0 ;
- XtSetArg( args[n], XmNorientation, XmHORIZONTAL ) ; n++ ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_NONE ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_WIDGET ) ; n++ ;
- XtSetArg( args[n], XmNbottomWidget, row ) ; n++ ;
- separator = XtCreateManagedWidget( "separator", xmSeparatorWidgetClass,
- form, args, n ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_WIDGET ) ; n++ ;
- XtSetArg( args[n], XmNbottomWidget, separator ) ; n++ ;
- XtSetArg( args[n], XmNhorizontalSpacing, 14 ) ; n++ ;
- XtSetArg( args[n], XmNverticalSpacing, 10 ) ; n++ ;
- form2 = XtCreateManagedWidget( "listForm2", xmFormWidgetClass, form,
- args, n ) ;
-
- str = XmStringCreateLocalized( title ) ;
- n = 0 ;
- XtSetArg( args[n], XmNlabelString, str ) ; n++ ;
- XtSetArg( args[n], XmNmarginTop, 15 ) ; n++ ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_NONE ) ; n++ ;
- label = XtCreateManagedWidget( "label", xmLabelWidgetClass, form2,
- args, n ) ;
- XmStringFree( str ) ;
-
- n = 0 ;
- XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ) ; n++ ;
- XtSetArg( args[n], XmNtopWidget, label ) ; n++ ;
- XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNrightAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNbottomAttachment, XmATTACH_FORM ) ; n++ ;
- XtSetArg( args[n], XmNvisibleItemCount, 5 ) ; n++ ;
- XtSetArg( args[n], XmNscrollBarDisplayPolicy, XmSTATIC ) ; n++ ;
- *list = XmCreateScrolledList( form2, "list", args, n ) ;
- XtManageChild( *list ) ;
- }
-